﻿using Gola.VN.Scb.Web.Dal;

namespace Gola.VN.Scb.Web.Bll
{
    internal class SysInfoBiz : BaseBiz
    {
        internal SysInfoBiz(MainDao mainDao)
            : base(mainDao)
        {
        }

        internal void InitializeData()
        {
            // 1. get data from database
            DaoPackage package = new DaoPackage();
            package.Channel = ChannelType.Sql;
            package.Event = DaoEvent.GetSysInfo;
            _mainDao.Execute(package);

            // 2. set data into memory
            package.Channel = ChannelType.Memory;
            package.Event = DaoEvent.SetSysInfo;
            package.Input = package.Output;
            _mainDao.Execute(package);
        }
        internal int GetSystemInfo()
        {
            DaoPackage package = new DaoPackage();
            package.Channel = ChannelType.Memory;
            package.Event = DaoEvent.GetSysInfo;
            _mainDao.Execute(package);

            return (int)package.Output ;
        }

        internal void UpdateSysInfo()
        {
            DaoPackage package = new DaoPackage();
            package.Channel = ChannelType.Sql;
            package.Event = DaoEvent.UpdateSysInfo;
            _mainDao.Execute(package);

            bool result = (bool)package.Output;
            if (result)
            {
                package.Channel = ChannelType.Memory;
                package.Event = DaoEvent.SetSysInfo;
                package.Input = 3;
                _mainDao.Execute(package);
            }
        }
    }
}
